/*提交表单的验证*/
function checkForm()
{	
	 uname=/^[\u4e00-\u9fa5]{2,5}$/;
	 if(!uname.test(form1.realName.value))
	 {
	form1.realName.focus()
	alert('姓名填写不正确，请填写正确姓名！');
	return false;
	 }
	
	
	var patrn=/^(13[0-9]|15[0-9]|18[0-9]|147|17[0-9])\d{8}$/;
	if (!patrn.exec(form1.mobile.value)){
	form1.mobile.focus()
	alert('手机号码格式不正确');
	return false;
	}
	
	if(form1.address.value.replace( / /g , "").length<5){
	alert("收货地址不正确！");
	form1.address.focus()
	return false;
	}

	function setCookie(name,value) //cookies设置JS 
	{ 
		var argv = setCookie.arguments; 
		var argc = setCookie.arguments.length; 
		var expires = (argc > 2) ? argv[2] : null; 
		if(expires!=null) 
			{ 
			var LargeExpDate = new Date (); 
			LargeExpDate.setTime(LargeExpDate.getTime() + (expires*1000*3600*1)); 
			} 
		document.cookie = name + "=" + escape (value)+((expires == null) ? "" : ("; expires=" +LargeExpDate.toGMTString())); 
	} 

	function getCookie(Name) //cookies读取JS 
	{ 
		var search = Name + "=" 
		if(document.cookie.length > 0) 
		{ 
			offset = document.cookie.indexOf(search) 
			if(offset != -1) 
		{ 
			offset += search.length 
			end = document.cookie.indexOf(";", offset) 
			if(end == -1) end = document.cookie.length 
			return unescape(document.cookie.substring(offset, end)) 
		} 
			else return "" 
		} 
	}

	if(getCookie("order")==null || getCookie("order")=="")
	{
		setCookie("order",1);
	}
	else
	{
		setCookie("order",parseInt(getCookie("order"))+1);
	}
	
	
	if(getCookie("order")>2)
	{
		alert("您的订单已提交！我们会在一个工作日受理。");
		return false;
	}
	
	$.ajax({
		type: 'POST',
		dataType: 'json',
		url:'/index.php/Home/Index/addmsg.html',
		data: $('#form1').serialize(),
		success: function (data) {
			alert(data['text']);
		},
		error: function(data) {
			alert("error:"+data['text']);
		}
	});
	return false;
	
	
}
